$(document).ready(function() {

	//alert($.cookie('tasktrackid'));
	$.ajax({
				type : "post",
				url : "lzw/taskTrack_queryTaskDetail.action",
				data : "taskid=" + $.cookie('tasktrackid'),
				dataType : "JSON",
				success : showPage,
				error : function(textStatus) {
					alert("Ajax请求失败，请检查本地的网络连接！");
					return false;
				}
			});



	function showPage(data) {
		var d = eval("(" + data + ")");
		if ((d.errMsg == "001" || d.errMsg == "000") && d.taskDetail != null) {
			$("#tNname").text(d.taskDetail.name);
			$("#stNo").text(d.taskDetail.EId);
			$("#tNo").text(d.taskDetail.id);
			$("#tContext").text(d.taskDetail.context);
			$("#tTime").text(d.taskDetail.time);
			$("#tState").text(d.taskDetail.status);
			$("#tdept").text(d.taskDetail.dept);
			$("#tPhone").text(d.taskDetail.phone);
			$("#tPeople").text(d.taskDetail.uname);
			$("#fdepts").text(d.taskDetail.leadDepts + "/"
					+ d.taskDetail.leadname);
			$("#fPhone").text(d.taskDetail.leadphone);

			$.each(d.taskDetail.annex, function(i, n) {

				var htmlStr = "";
				htmlStr += "<div><img src='lzm/images/doc.gif'/>";
				htmlStr += "<span class='moduleID' style='display:none;'>";
				htmlStr += $.trim(n.moduleId);
				htmlStr += "</span><span class='filename'>"
				htmlStr += n.filename;
				htmlStr += "</span>";
				htmlStr += "<span class='fileid' style='display:none;'>";
				htmlStr += $.trim(n.fileid);
				htmlStr += "</span><a style='margin-left:10px;cursor:pointer;' class='fjURL' onclick='downloadFile(this)'>点击下载</a></div>";

				$('#taskAnnexDiv').append(htmlStr);
			});

			var taskid = $.trim(d.taskDetail.id);
			$.cookie('tasktrackid', taskid);
			var eventid = $.trim(d.taskDetail.EId);
			$.cookie('taskEventId', eventid);
		} else {
			alert(d.errMsg);
			$('#mainFrame', window.parent.document).attr("src",
					"/ag/lzw/task_detail_main.jsp");
			return false;
		}
	}
});

	// file download start :hmk

	function downloadFile(v) {
		var path = $(v).prev().text();
		var filename = $(v).prev().prev().text();
		var moduelId = $(v).prev().prev().prev().text();
		window.location.href = "/ag/file/download.action?fileRealName="
				+ $.trim(filename) + "&fileDiskURL=" + $.trim(path)
				+ "&moduleID=" + $.trim(moduelId);
		// url :
		// "file/download.action?fileRealName="+$.trim(filename)+"&fileDiskURL="+$.trim(path)+"&moduleID="+$.trim(moduelId),
	}
	// file download end :hmk
